<?php

Raise::load('library.oauth.response.RaiseOAuthResponse');
Raise::load('library.oauth.core.RaiseOAuthUtility');
Raise::load('core.collection.RaiseCollection');

class RaiseOAuthRequestTokenResponse extends RaiseOAuthResponse {
    
    const KEY_CALLBACK_CONFIRMED = 'oauth_callback_confirmed';
    
    /**
     *
     * @var string
     */
    private $callbackConfirmed;
    
    public function parse($response) {
        $a = $this->internalParse($response);
        
        $this->token = $a->get(self::KEY_TOKEN);
        $this->tokenSecret = $a->get(self::KEY_TOKEN_SECRET);
        $this->callbackConfirmed = $a->get(self::KEY_CALLBACK_CONFIRMED);
    }

    public function response() {
        $a = new RaiseCollection();
        $a->add(self::KEY_TOKEN, $this->token);
        $a->add(self::KEY_TOKEN_SECRET, $this->tokenSecret);
        $a->add(self::KEY_CALLBACK_CONFIRMED, $this->callbackConfirmed);
        
        return RaiseOAuthUtility::buildQuery($a->toArray());
    }

    /**
     * Get or set $description$
     * @param string $c (optional) $description$
     * @return string
     */
    public function callbackConfirmed($c = null){
        if(func_num_args() == 1){
            $this->callbackConfirmed = $c;
        }
        return $this->callbackConfirmed;
    }
    
}